/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vn.ac.c0910g.assignment.DAO;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import vn.ac.c0910g.assignment.Entity.Faqs;
import vn.ac.c0910g.assignment.Entity.FaqsFacade;

/**
 *
 * @author BachLe
 */
public class FaqsDAO {
    FaqsFacade faqsFacade = lookupFaqsFacadeBean();

    public FaqsDAO(){

    }
    private FaqsFacade lookupFaqsFacadeBean() {
        try {
            Context c = new InitialContext();
            return (FaqsFacade) c.lookup("java:global/Alluring_Decors/Alluring_Decors-ejb/FaqsFacade!vn.ac.c0910g.assignment.Entity.FaqsFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    public List<Faqs> getAllFaqs(){
        return this.faqsFacade.findAll();
    }

    public void addFaqs(Faqs f){
        faqsFacade.create(f);
    }

    public void updateFaqs(Faqs f){
        faqsFacade.edit(f);
    }

    public void deleteFaqsa(Faqs f){
        faqsFacade.remove(f);
    }

    public Faqs findFaqsById(String Id){
        return faqsFacade.find(Id);
    }
}
